package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.Travel;
import cn.wolfcode.wolf2w.query.TravelQuery;
import cn.wolfcode.wolf2w.service.ITravelService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

//目的地后端控制器
@Controller
@RequestMapping("/travel")
public class TravelController {

    @Autowired
    private ITravelService travelService;

    /**
     * 高查
     * @param model
     * @param qo
     * @return
     */
    @RequestMapping("/list")
    public String list(Model model,@ModelAttribute("qo") TravelQuery qo) {
        //高查(加入导航吐司条件进行高查)
        model.addAttribute("page",travelService.query(qo));
        return "/travel/list";
    }

    /**
     * 提供指定标题游记内容
     * @param id
     * @return
     */
    @RequestMapping("/getContentById")
    @ResponseBody
    public Object getContentById(String id) {
        Travel travel = travelService.findByOne(id);
        return JsonResult.success(travel.getContent());
    }

    /**
     * 审核
     * @param id
     * @param state
     * @return
     */
    @RequestMapping("/audit")
    @ResponseBody
    public Object audit(String id,int state) {
        travelService.audit(id,state);
        return JsonResult.success();
    }



}

